home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15313 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.magmacom.com!not-for-mail
  2. From: ezust@mag1.magmacom.com (Acme Instant Dehydrated Boulder Kit)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: delete or delete [] ?
  5. Date: 4 Apr 1996 13:44:51 -0500
  6. Organization: Cloud-Zero, Canada
  7. Message-ID: <4k15b3$f83@mag1.magmacom.com>
  8. References: <4jpe5j$3vo@doc.zippo.com> <4ju30g$96q@cloner2.ix.netcom.com>
  9. NNTP-Posting-Host: mag1.magmacom.com
  10.  
  11. In article <4ju30g$96q@cloner2.ix.netcom.com>,
  12. John Lilley <jlilley@ix.netcom.com> wrote:
  13. >
  14. >Please be careful giving advice on this!  The operators delete and delete[] need not 
  15. >be implemented identically, especially since in the ANSI draft (and I believe the 
  16. >ARM?) one can override one operator pair (new/delete or new[]/delete[]) without the 
  17. >overriding the other.  In addition, some implementations of new[]/delete[] allocate 
  18. >data preceding the returned memory pointer to keep track of the number and size of 
  19. >the objects in the array.
  20. >
  21. >The rule is:  if you allocate with new[], then free with delete[].
  22. >In your example, I believe that operator new[] is called for allocation,
  23. >since the type is an array, so call operator delete[] to free it.
  24. >
  25.  
  26. in the example, he was NOT allocating with new[]. The typedef was like this
  27.  
  28. typedef int int10[10];
  29.  
  30. int* ip = new int10;
  31.  
  32. No new[] operator used here. So by that logic he shouldn't be using
  33. delete[].
  34.  
  35. -- 
  36. Alan Ezust                       "Just because I work for the federal
  37. Ottawa, Canada                    government doesn't mean I'm an expert
  38. ezust@magmacom.com                on cockroaches"  -Special Agent Fox Mulder
  39. http://www2.magmacom.com/~ezust   
  40.